package com.ler.yrmall.ware.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.ler.yrmall.basic.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * @author Leron
 * 采购清单
 */
@Data
@TableName("wms_purchase_detail")
@EqualsAndHashCode(callSuper = true)
public class PurchaseDetailEntity extends BaseEntity<PurchaseDetailEntity> {

    /**
     * 采购单id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long purchaseId;

    /**
     * 采购商品id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long skuId;

    /**
     * 采购数量
     */
    private Integer skuNum;

    /**
     * 仓库id
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long wareId;

    /**
     * @see PurchaseDetailStatus
     */
    private Integer status;

    /**
     * 完成时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime finishTime;

    /**
     * 清单状态
     */
    public enum PurchaseDetailStatus {

        /**
         * 状态
         */
        CREATED(0,"未开始"),

        PROCESS(1,"处理中"),

        FINISH(2,"已完成"),

        FAIL(3,"采购失败");

        private final Integer code;

        private final String dict;

        PurchaseDetailStatus(Integer code, String dict) {
            this.code = code;
            this.dict = dict;
        }

        public Integer getCode() {
            return code;
        }

        public String getDict() {
            return dict;
        }

    }

}
